<%@page import="Configurations.SALT"%>
<%
    session.setAttribute("displayPage", "encrypt");
    // Redirect if this page is being displayed by itself
    if (request.getServletPath().equals("/encrypt.jsp")) {
        System.out.println("Current Page is set to encrypt. Redirect to index.jsp");
        response.sendRedirect("");
    }

    // If a password has been submitted to be encrypted, store the information
    String password = "";
    String encrypted = "";
    if (request.getParameter("pass") != null) {
        try {
            password = request.getParameter("pass");
            encrypted = SALT.encrypt(password);
        } catch (Exception e) {
        }
    }
%>
<h3>Encrypt Password</h3>
<div id="content">
    <form action="" method="post">
        <table border="1" width="100%">
            <tr align="center">
                <td>
                    <b>Enter a password to encrypt:</b>
                </td>
                <td>
                    <input type="text" name="pass" value="<%=password%>" size="64"/>
                </td>
            </tr>
            <tr align="center">
                <td>
                    <b>Encrypted String:</b>
                </td>
                <td>
                    <%=encrypted%>
                </td>
            </tr>
        </table>
        <br/>
        <input type="submit" value="Encrypt" />
    </form>
</div>
<br/>